<?php
/**
 * front controller class
 *
 * @author raphael seebacher <raphasee@ee.ethz.ch>
 * @version 0.1
 */
abstract class front_controller extends controller {
    final public function __construct($request) {
        $this->request = $request;
    }

    final public static function get() {
        $request = new request();

        if (api_controller::is_valid_request_url($request)) {
            return new api_controller($request);
        }
        else {
            session_save_path($_SERVER['DOCUMENT_ROOT'].'../data/sessions');
            session_start();

            if (ajax_controller::is_valid_request_url($request)) {
                return new ajax_controller($request);
            }
            else {
                return new web_controller($request);
            }
        }
    }

    abstract public static function is_valid_request_url($request);
    abstract public function process_request();
}
?>